package com.ark.cloud.java.persistence.service.impl;


import com.ark.cloud.java.persistence.entity.EntityType;
import com.ark.cloud.java.persistence.entity.FireEvent;
import com.ark.cloud.java.persistence.mapper.EntityTypeMapper;
import com.ark.cloud.java.persistence.mapper.FireEventMapper;
import com.ark.cloud.java.persistence.service.FireEventService;
import com.ark.cloud.java.persistence.utils.UUIDUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author fukun
 * @create 2021/8/31  下午4:57
 * @description
 */
@Service
public class FireEventServiceImpl extends ServiceImpl<FireEventMapper, FireEvent> implements FireEventService {

    @Autowired
    FireEventMapper fireEventDao;
    @Autowired
    EntityTypeMapper entityTypeDao;

    @Override
    public void saveFireEventInfo(FireEvent fireEvent) {

        //设置主键
        fireEvent.setId(UUIDUtil.next());

        System.out.println("fireEvent:"+fireEvent);

        // entity_type表插入
        EntityType munitionType = fireEvent.getMunitionType();
        System.out.println("munitionType:"+munitionType);
        munitionType.setId(UUIDUtil.next());
        entityTypeDao.insert(munitionType);

        Long id = munitionType.getId();

        // fire_event表插入
        fireEvent.setTypeId(id);

        fireEventDao.saveFireEventInfo(fireEvent);

    }
}
